package com.wh1200.mybatis.xmlless.enums

/**
 * 数据库支持的操作符
 * @author 吴昊
 * @since 0.0.1
 */
enum class Operations(
    val operator: String,
    val parameterCount: Int,
    val expression: String = ""
) {

  /** {property} between ? and ? */
  Between("BETWEEN", 2),

  /** {property} = ? */
  Eq("=", 1),

  /** date_format({property}, '%Y-%m-%d') = date_format(?, '%Y-%m-%d') */
  EqDate("=", 1),
  EqDefault("=", 0),

  /** {property} = false */
  EqFalse("= FALSE", 0),

  NotTrue("= FALSE", 0),

  /** date_format({property}, '%Y-%m') = date_format(?, '%Y-%m') */
  EqMonth("=", 1),

  /** {property} = true */
  True("= TRUE", 0),
  EqTrue("= TRUE", 0),

  /** {property} > ? */
  Gt("&gt;", 1),

  /** date_format({property}, '%Y-%m-%d') > date_format(?, '%Y-%m-%d') */
  GtDate("&gt;", 1),

  /** {property} >= ? */
  Gte("&gt;=", 1),

  /** date_format({property}, '%Y-%m-%d') >= date_format(?, '%Y-%m-%d') */
  GteDate("&gt;=", 1),

  Contains("", 1, "CONTAINS"),

  ContainsAny("", 1, "CONTAINS ANY"),

  /** {property} in ? */
  In("IN", 1),
  NotIn("NOT IN", 1),

  /** {property} is not null */
  IsNotNull("IS NOT NULL", 0),

  /** {property} is null */
  IsNull("IS NULL", 0),

  /** {property} like CONCAT('%', ?, '%') */
  Like("LIKE", 1),
  Ilike("ILIKE", 1),
  IlikeLeft("ILIKE", 1),
  IlikeRight("ILIKE", 1),

  /** {property} like CONCAT('%', ?) */
  LikeLeft("LIKE", 1),

  /** {property} like CONCAT(?, '%') */
  LikeRight("LIKE", 1),

  /** {property} < ? */
  Lt("&lt;", 1),

  /** date_format({property}, '%Y-%m-%d') < date_format(?, '%Y-%m-%d') */
  LtDate("&lt;", 1),

  /** {property} <= ? */
  Lte("&lt;=", 1),

  /** date_format({property}, '%Y-%m-%d') <= date_format(?, '%Y-%m-%d') */
  LteDate("&lt;", 1),

  /** {property} != ? */
  Ne("!=", 1),

  Not("!=", 1),

  /** date_format({property}, '%Y-%m-%d') != date_format(?, '%Y-%m-%d') */
  NeDate("!=", 1),

  /** 同IsNotNull */
  NotNull("IS NOT NULL", 0);

}
